<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<p>Make TextCheckingParagraph.subrange() handles null position returned by
endSentence() in multiple chunks case in
SpellChecker::chunkAndMarkAllMisspellingsAndBadGrammar()
</p>
<ul>
<li id="sample" contenteditable="true">foo <span id="words"></span>
<div contenteditable="false" style="-webkit-user-select: none">uneditable</div>
</li>
</ul>
<div id="log"></div>
<script>
if (window.testRunner)
    testRunner.setMockSpellCheckerEnabled(true);

test(function() {
    // Make text for spell checking longer than |kChunkSize|=16*1024 defined in
    // SpellChecker::chunkAndMarkAllMisspellingsAndBadGrammar()
    var words = document.getElementById('words');
    words.textContent = ' 123'.repeat(1024 * 4);

    // Trigger spell checking
    window.getSelection().collapse(document.getElementById('sample'), 0);

    if (window.internals)
      internals.runIdleTimeSpellChecker(document);
});
</script>
